/*     */ package eos.moe.dragoncore;
/*     */ 
/*     */ import java.lang.reflect.Constructor;
/*     */ import java.util.ArrayList;
/*     */ import java.util.HashMap;
/*     */ import java.util.List;
/*     */ import java.util.Map;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class qb
/*     */ {
/*     */   public Map<String, uc> q;
/*     */   public Map<String, Class<? extends va>> g;
/*     */   
/*     */   public qb() {
/*  28 */     this.q = new HashMap<>();
/*  29 */     this.g = new HashMap<>();
/*  30 */     v(new uc("PI", Math.PI));
/*  31 */     v(new uc("E", Math.E));
/*  32 */     this.g.put("floor", tb.class);
/*  33 */     this.g.put("round", jb.class);
/*  34 */     this.g.put("ceil", rb.class);
/*  35 */     this.g.put("trunc", lb.class);
/*  36 */     this.g.put("clamp", oc.class);
/*  37 */     this.g.put("max", vc.class);
/*  38 */     this.g.put("min", yc.class);
/*  39 */     this.g.put("abs", qc.class);
/*  40 */     this.g.put("cos", dc.class);
/*  41 */     this.g.put("sin", lc.class);
/*  42 */     this.g.put("exp", fc.class);
/*  43 */     this.g.put("ln", cc.class);
/*  44 */     this.g.put("sqrt", mc.class);
/*  45 */     this.g.put("mod", bc.class);
/*  46 */     this.g.put("pow", hc.class);
/*  47 */     this.g.put("lerp", fb.class);
/*  48 */     this.g.put("lerprotate", pb.class);
/*  49 */     this.g.put("random", ub.class);
/*     */   }
/*     */   
/*     */   public void v(uc uc1) {
/*  53 */     this.q.put(uc1.v(), uc1);
/*     */   }
/*     */   
/*     */   public b v(String str) throws Exception {
/*  57 */     return z(v(v(str)));
/*     */   }
/*     */   
/*     */   public String[] v(String str) throws Exception {
/*  61 */     if (!str.matches("^[\\w\\d\\s_+-/*%^&|<>=!?:.,()]+$")) {
/*  62 */       throw new Exception("Given expression '" + str + "' contains illegal characters!");
/*     */     }
/*  64 */     str = str.replaceAll("\\s+", "");
/*  65 */     String[] arrayOfString = str.split("(?!^)");
/*  66 */     int i = 0;
/*  67 */     int j = 0;
/*  68 */     for (String str1 : arrayOfString) {
/*  69 */       if (str1.equals("(")) {
/*  70 */         i++;
/*  71 */       } else if (str1.equals(")")) {
/*  72 */         j++;
/*     */       } 
/*     */     } 
/*  75 */     if (i != j) {
/*  76 */       throw new Exception("Given expression '" + str + "' has more uneven amount of parenthesis, there are " + i + " open and " + j + " closed!");
/*     */     }
/*  78 */     return arrayOfString;
/*     */   }
/*     */   
/*     */   public List<Object> v(String[] arrayOfString) {
/*  82 */     List<E> list = new ArrayList();
/*  83 */     String str = "";
/*  84 */     for (int i = arrayOfString.length, j = 0; j < i; j++) {
/*  85 */       String str1 = arrayOfString[j];
/*  86 */       boolean bool = (j > 0 && z(arrayOfString[j - 1] + str1));
/*  87 */       if (z(str1) || bool || str1.equals(",")) {
/*  88 */         if (str1.equals("-")) {
/*  89 */           int k = list.size();
/*  90 */           boolean bool1 = (k == 0 && str.isEmpty());
/*  91 */           boolean bool2 = (k > 0 && (v(list.get(k - 1)) || list.get(k - 1).equals(",")) && str.isEmpty());
/*  92 */           if (bool1 || bool2) {
/*  93 */             str = str + str1;
/*     */             continue;
/*     */           } 
/*     */         } 
/*  97 */         if (bool) {
/*  98 */           str1 = arrayOfString[j - 1] + str1;
/*  99 */           str = str.substring(0, str.length() - 1);
/*     */         } 
/* 101 */         if (!str.isEmpty()) {
/* 102 */           list.add((E)str);
/* 103 */           str = "";
/*     */         } 
/* 105 */         list.add((E)str1); continue;
/* 106 */       }  if (str1.equals("(")) {
/* 107 */         if (!str.isEmpty()) {
/* 108 */           list.add((E)str);
/* 109 */           str = "";
/*     */         } 
/* 111 */         int k = 1;
/* 112 */         for (int m = j + 1; m < i; m++) {
/* 113 */           String str2 = arrayOfString[m];
/* 114 */           if (str2.equals("(")) {
/* 115 */             k++;
/* 116 */           } else if (str2.equals(")")) {
/* 117 */             k--;
/*     */           } 
/* 119 */           if (k == 0) {
/* 120 */             list.add((E)v(str.split("(?!^)")));
/* 121 */             j = m;
/* 122 */             str = "";
/*     */             break;
/*     */           } 
/* 125 */           str = str + str2;
/*     */         } 
/*     */       } else {
/* 128 */         str = str + str1;
/*     */       }  continue;
/*     */     } 
/* 131 */     if (!str.isEmpty()) {
/* 132 */       list.add((E)str);
/*     */     }
/* 134 */     return (List)list;
/*     */   }
/*     */   
/*     */   public b z(List<Object> list) throws Exception {
/* 138 */     b b = v(list);
/* 139 */     if (b != null) {
/* 140 */       return b;
/*     */     }
/* 142 */     int i = list.size();
/* 143 */     if (i == 1) {
/* 144 */       return v(list.get(0));
/*     */     }
/* 146 */     if (i == 2) {
/* 147 */       Object object1 = list.get(0);
/* 148 */       Object object2 = list.get(1);
/* 149 */       if ((z(object1) || object1.equals("-")) && object2 instanceof List) {
/* 150 */         return v((String)object1, (List<Object>)object2);
/*     */       }
/*     */     } 
/*     */     
/*     */     int j, k;
/*     */     
/* 156 */     for (k = j = z(list); j != -1; j = m) {
/* 157 */       int m = z(list, j - 1);
/* 158 */       if (m != -1) {
/* 159 */         ec ec1 = v(list.get(m));
/* 160 */         ec ec2 = v(list.get(j));
/* 161 */         if (ec2.q > ec1.q) {
/* 162 */           b b1 = z(list.subList(0, m));
/* 163 */           b b2 = z(list.subList(m + 1, i));
/* 164 */           return new jc(ec1, b1, b2);
/*     */         } 
/* 166 */         if (ec1.q > ec2.q) {
/* 167 */           ec ec3 = v(list.get(k));
/* 168 */           if (ec3.q < ec1.q) {
/* 169 */             b b3 = z(list.subList(0, k));
/* 170 */             b b4 = z(list.subList(k + 1, i));
/* 171 */             return new jc(ec3, b3, b4);
/*     */           } 
/* 173 */           b b1 = z(list.subList(0, j));
/* 174 */           b b2 = z(list.subList(j + 1, i));
/* 175 */           return new jc(ec2, b1, b2);
/*     */         } 
/*     */       } 
/*     */     } 
/* 179 */     ec ec = v(list.get(k));
/* 180 */     return new jc(ec, z(list.subList(0, k)), z(list.subList(k + 1, i)));
/*     */   }
/*     */   
/*     */   public int z(List<Object> list) {
/* 184 */     return z(list, list.size() - 1);
/*     */   }
/*     */   
/*     */   public int z(List list, int i) {
/* 188 */     for (int j = i; j >= 0; j--) {
/* 189 */       Object object = list.get(j);
/* 190 */       if (v(object)) {
/* 191 */         return j;
/*     */       }
/*     */     } 
/* 194 */     return -1;
/*     */   }
/*     */   
/*     */   public int v(List<Object> list) {
/* 198 */     return v(list, 0);
/*     */   }
/*     */   
/*     */   public int v(List list, int i) {
/* 202 */     for (int j = i, k = list.size(); j < k; j++) {
/* 203 */       Object object = list.get(j);
/* 204 */       if (v(object)) {
/* 205 */         return j;
/*     */       }
/*     */     } 
/* 208 */     return -1;
/*     */   }
/*     */   
/*     */   public b v(List<Object> list) throws Exception {
/* 212 */     int i = -1;
/* 213 */     int j = 0;
/* 214 */     int k = -1;
/* 215 */     int m = 0;
/* 216 */     int n = list.size();
/* 217 */     for (int i1 = 0; i1 < n; i1++) {
/* 218 */       Object object = list.get(i1);
/* 219 */       if (object instanceof String) {
/* 220 */         if (object.equals("?")) {
/* 221 */           if (i == -1) {
/* 222 */             i = i1;
/*     */           }
/* 224 */           j++;
/* 225 */         } else if (object.equals(":")) {
/* 226 */           if (m + 1 == j && k == -1) {
/* 227 */             k = i1;
/*     */           }
/* 229 */           m++;
/*     */         } 
/*     */       }
/*     */     } 
/* 233 */     if (j == m && i > 0 && i + 1 < k && k < n - 1) {
/* 234 */       return new ic(z(list.subList(0, i)), z(list.subList(i + 1, k)), z(list.subList(k + 1, n)));
/*     */     }
/* 236 */     return null;
/*     */   }
/*     */   
/*     */   public b v(String str, List<Object> list) throws Exception {
/* 240 */     if (str.equals("!")) {
/* 241 */       return new ri(z(list));
/*     */     }
/* 243 */     if (str.startsWith("!") && str.length() > 1) {
/* 244 */       return new ri(v(str.substring(1), list));
/*     */     }
/* 246 */     if (str.equals("-")) {
/* 247 */       return new vk(z(list));
/*     */     }
/* 249 */     if (str.startsWith("-") && str.length() > 1) {
/* 250 */       return new vk(v(str.substring(1), list));
/*     */     }
/* 252 */     if (!this.g.containsKey(str)) {
/* 253 */       throw new Exception("Function '" + str + "' couldn't be found!");
/*     */     }
/* 255 */     List<b> list1 = new ArrayList();
/* 256 */     List<Object> list2 = new ArrayList();
/* 257 */     for (Object object : list) {
/* 258 */       if (object.equals(",")) {
/* 259 */         list1.add(z(list2));
/* 260 */         list2.clear(); continue;
/*     */       } 
/* 262 */       list2.add(object);
/*     */     } 
/*     */     
/* 265 */     if (!list2.isEmpty()) {
/* 266 */       list1.add(z(list2));
/*     */     }
/* 268 */     Class clazz = this.g.get(str);
/* 269 */     Constructor<va> constructor = clazz.getConstructor(new Class[] { b[].class, String.class });
/* 270 */     va va = constructor.newInstance(new Object[] { list1.toArray(new b[list1.size()]), str });
/* 271 */     return va;
/*     */   }
/*     */   
/*     */   public b v(Object object) throws Exception {
/* 275 */     if (object instanceof String) {
/* 276 */       String str = (String)object;
/* 277 */       if (str.startsWith("!")) {
/* 278 */         return new ri(v(str.substring(1)));
/*     */       }
/* 280 */       if (v(str)) {
/* 281 */         return new il(Double.parseDouble(str));
/*     */       }
/* 283 */       if (z(str)) {
/* 284 */         if (str.startsWith("-")) {
/* 285 */           str = str.substring(1);
/* 286 */           uc uc = v(str);
/* 287 */           if (uc != null) {
/* 288 */             return new vk(uc);
/*     */           }
/*     */         } else {
/* 291 */           b b = v(str);
/* 292 */           if (b != null) {
/* 293 */             return b;
/*     */           }
/*     */         } 
/*     */       }
/* 297 */     } else if (object instanceof List) {
/* 298 */       return new vg(z((List<Object>)object));
/*     */     } 
/* 300 */     throw new Exception("Given object couldn't be converted to value! " + object);
/*     */   }
/*     */   
/*     */   public uc v(String str) {
/* 304 */     return this.q.get(str);
/*     */   }
/*     */   
/*     */   public ec v(Object object) throws Exception {
/* 308 */     for (ec ec : ec.values()) {
/* 309 */       if (ec.w.equals(object)) {
/* 310 */         return ec;
/*     */       }
/*     */     } 
/* 313 */     throw new Exception("There is no such operator '" + object + "'!");
/*     */   }
/*     */   
/*     */   public boolean z(Object object) {
/* 317 */     return (object instanceof String && !v((String)object) && !z((String)object));
/*     */   }
/*     */   
/*     */   public boolean v(Object object) {
/* 321 */     return (object instanceof String && z((String)object));
/*     */   }
/*     */   
/*     */   public boolean z(String str) {
/* 325 */     return (ec.i.contains(str) || str.equals("?") || str.equals(":"));
/*     */   }
/*     */   
/*     */   public boolean v(String str) {
/* 329 */     return str.matches("^-?\\d+(\\.\\d+)?$");
/*     */   }
/*     */ }


/* Location:              D:\fanbian\[D][龙之核心]DragonCore-2.6.0.3.jar!\eos\moe\dragoncore\qb.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */